<?
$pageName = "courseClass";
include ROOT . '/view/admin/common/header.php';
?>
<?
/**
 * @var	$page_nav
 * @var	$data
 * @var	CourseClass	$courseClass
 * @var $classTimes
 * @var  ClassTime  $classTime
 */
?>
    <div class="container">
        <div class="page-header">
            <br /><br />
            <h2>
                <label>开课班管理</label>
                <a href="/admin/courseClass/edit/" class="btn btn-danger" style="float:right; margin-right:20px">添加开课班</a>
                <button type="button" style="float: right; margin-right:20px" class="btn btn-info" data-toggle="modal" data-target="#Search">搜索</button>
            </h2>
        </div>
        <div class="row" style="margin-bottom:30px;">
            <div class="col-xs-12">
                <h3>
                    课程记录 <small>共计<?=$page_nav['count']?>条</small>
                </h3>
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>课程名</th>
                        <th>学分数</th>
                        <th>任课教师</th>
                        <th>开课学期</th>
                        <th>最大容纳人数</th>
                        <th>教室</th>
                        <th>上课时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?
                        foreach($data as $courseClass) {
                            $rowSpan = count($classTimes[$courseClass->id]);
                    ?>
                        <tr>
                            <td rowspan="<?=$rowSpan?>"><?=$courseClass->course()->name?></td>
                            <td rowspan="<?=$rowSpan?>"><?=$courseClass->course()->credit?></td>
                            <td rowspan="<?=$rowSpan?>"><?=$courseClass->teacher()->name?></td>
                            <td rowspan="<?=$rowSpan?>"><?=$courseClass->semester?></td>
                            <td rowspan="<?=$rowSpan?>"><?=$courseClass->capacity?></td>
                            <td rowspan="<?=$rowSpan?>"><?=$courseClass->classroom()->name?></td>
                            <td rowspan="<?=$rowSpan?>">
                                <?
                                    foreach ($classTimes[$courseClass->id] as $classTime) echo "{$classTime->showDay()}&nbsp;&nbsp;&nbsp;{$classTime->startTime}-{$classTime->endTime}节<br/>";
                                ?>
                            </td>
                            <td rowspan="<?=$rowSpan?>">
                                <a href="/admin/courseClass/edit/<?=$courseClass->id?>/">编辑</a> |
                                <a href="/admin/courseClass/delete/<?=$courseClass->id?>/" onclick="return confirm('确认要删除开课班“<?=$courseClass->name?>”吗？')">删除</a>
                            </td>
                        </tr>
                        <?
                            for ($i = 0; $i < $rowSpan - 1; $i++) echo "<tr></tr>";
                            if ($i % 2 != 0) echo "<tr></tr>"; //correct the color of the next row
                        ?>
                    <?}?>
                    </tbody>
                </table>
            </div>

        </div>
        <!-- .row -->
        <center><div class="subpages row"><ul class="pagination pagination-sm"><?=$page_nav['nav']?></ul></div></center>
    </div>
    <!--搜索-->
    <div class="modal fade" id="Search" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <form class="form-horizontal" role="form" method="get" action="">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">条件搜索</h4>
                    </div>
                    <div class="modal-body">
                        <h4>课程名</h4>
                        <input id="search" name="search" type="text" class="form-control input-lg" placeholder="" value=""><br>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-warning btn-block">提交</button>
                    </div>
                </form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
<? include ROOT . '/view/common/footer.php'; ?>